package com.seari.tunnel.controller;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

import com.seari.tunnel.entity.ConstructionLog;
import com.seari.tunnel.entity.ConstructionLogParam;
import com.seari.tunnel.entity.ConstructionManage;
import com.seari.tunnel.entity.ConstructionType;
import com.seari.tunnel.entity.CorridorIn;
import com.seari.tunnel.entity.CorridorInParam;
import com.seari.tunnel.entity.CorridorOut;
import com.seari.tunnel.entity.CorridorOutParam;
import com.seari.tunnel.entity.DeductStandard;
import com.seari.tunnel.entity.FeeConfig;
import com.seari.tunnel.entity.Namber;
import com.seari.tunnel.entity.PayHistory;
import com.seari.tunnel.entity.PayHistoryParam;
import com.seari.tunnel.entity.PayName;
import com.seari.tunnel.entity.PileNo;
import com.seari.tunnel.entity.PipelineArchives;
import com.seari.tunnel.entity.PipelineInfo;
import com.seari.tunnel.entity.PipelineInfoParam;
import com.seari.tunnel.entity.PipelineType;
import com.seari.tunnel.entity.Plies;
import com.seari.tunnel.entity.Role;
import com.seari.tunnel.entity.ServiceApplication;
import com.seari.tunnel.entity.ServiceApplicationParam;
import com.seari.tunnel.entity.ServiceType;
import com.seari.tunnel.entity.SupervisionLog;
import com.seari.tunnel.entity.VisitApply;
import com.seari.tunnel.entity.VisitApplyPage;
import com.seari.tunnel.entity.WarehouseSection;
import com.seari.tunnel.security.ShiroUser;
import com.seari.tunnel.service.IAcceptService;
import com.seari.tunnel.service.IAgreementService;
import com.seari.tunnel.service.IConstructionService;
import com.seari.tunnel.service.IPayFeeService;
import com.seari.tunnel.service.IProcedureService;
import com.seari.tunnel.service.IUserService;

@Controller
public class LineBusinessController {
  private final static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  private final static SimpleDateFormat nsdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  
  private final String GXYW_PAGE = "/gxyw";
  private final String SQBDOWNUP_PAGE = "/sqbDownUp";
  private final String SQBRECORD_PAGE = "/sqbRecord";
  private final String YWCZ_PAGE = "/ywcz";
  private final String YWDA_PAGE = "/ywda";
  private final String FAYZ_PAGE = "/fayz";
  private final String SHBDOWNUP_PAGE = "/shbDownUp";
  private final String HTMBDOWNUP_PAGE = "/htmbDownUp";
  private final String HTDA_PAGE = "/htba";
  private final String XKGL_PAGE = "/xkgl";
  private final String BZJGL_PAGE = "/bzjgl";
  private final String FWSQ_PAGE = "/fwsq";
  private final String SGRZ_PAGE = "/sgrz";
  private final String SGJDRZ_PAGE = "/sgjdrz";
  private final String JFRECORD_PAGE = "/jfRecord";
  private final String FEESIMULATE_PAGE = "/feeSimulate";
  private final String VISITAPPLY_PAGE = "/visitApply";
  private final String RLSQEDIT_PAGE = "/rlsqEdit";
  private final String YWDAEDIT_PAGE = "/ywdaEdit";
  private final String HTDAEDIT_PAGE = "/htdaEdit";
  private final String XKGLEDIT_PAGE = "/xkglEdit";
  private final String BZJEDIT_PAGE ="/bzjEdit";
  private final String FWSQEDIT_PAGE = "/fwsqEdit";
  private final String SGJLEDIT_PAGE = "/sgjlEdit";
  private final String JFJLEDIT_PAGE = "/jfjlEdit";
  private final String GXDAEDIT_PAGE = "/gxdaEdit";
  
  private final String SAVE_PATH = "C:/save/";
  
  @Autowired
  IAcceptService acceptService;
  @Autowired
  IAgreementService agreementService;
  @Autowired
  IProcedureService procedureService;
  @Autowired
  IPayFeeService payFeeService;
  @Autowired
  IConstructionService constructionService;
  @Autowired
  IUserService userService;
	
	@RequestMapping(value="/gxyw")
	public ModelAndView gxyw(){
		
		return new ModelAndView(GXYW_PAGE);
	}
	
	@RequiresRoles(value = {"admin","ownership"}, logical = Logical.OR)
	@RequestMapping(value="/sqbDownUp")
	public ModelAndView sqbDownUp(@RequestParam("compId") String compId,@RequestParam("compName") String compName,@RequestParam("phoneNo") String phoneNo){
		try {
			compName = new String(compName.getBytes("ISO8859-1"),"UTF-8");
		} catch (UnsupportedEncodingException e) {
			
			e.printStackTrace();
		}
		return new ModelAndView(SQBDOWNUP_PAGE)
		.addObject("compId", compId)
		.addObject("compName", compName)
		.addObject("phoneNo", phoneNo);
	}
	
	@RequestMapping(value="/sqbRecord")
	public ModelAndView sqbRecord(){
		
		return new ModelAndView(SQBRECORD_PAGE);
	}
	
	@RequiresRoles(value = {"admin","operator"}, logical = Logical.OR)
	@RequestMapping(value="/ywcz")
	public ModelAndView ywcz(@RequestParam("compId") String compId,@RequestParam("compName") String compName){
		if(compId!=""&&compName!=""){
		try {
			compName = new String(compName.getBytes("ISO8859-1"),"UTF-8");
		} catch (UnsupportedEncodingException e) {
			
			e.printStackTrace();
		}
		CorridorIn ci = constructionService.findCorridorInById(Integer.parseInt(compId));
		return new ModelAndView(YWCZ_PAGE)
		.addObject("compId", compId)
		.addObject("compName", compName)
		.addObject("pt_id", ci.getPt_id())
		.addObject("sws_id", ci.getSws_id())
		.addObject("ews_id", ci.getEws_id());
		}
		return new ModelAndView(YWCZ_PAGE)
		.addObject("compId", compId)
		.addObject("compName", compName)
		.addObject("pt_id", "")
		.addObject("sws_id", "")
		.addObject("ews_id", "");
	}
	
	@RequestMapping(value="/loadCIBySelect")
	@ResponseBody
	public Object loadCIBySelect(@RequestParam("compId") String compId){
		CorridorIn ci = constructionService.findCorridorInById(Integer.parseInt(compId));
		return ci;
	}
	
	@RequestMapping(value="/ywda")
	public ModelAndView ywda(){
		
		return new ModelAndView(YWDA_PAGE);
	}
	
	@RequiresRoles(value = {"admin","ownership"}, logical = Logical.OR)
	@RequestMapping(value="/htmbDownUp")
	public ModelAndView htmbDownUp(){
		
		return new ModelAndView(HTMBDOWNUP_PAGE);
	}
	
	@RequiresRoles(value = {"admin","ownership","regulator","projectManager"}, logical = Logical.OR)
	@RequestMapping(value="/htda")
	public ModelAndView htda(){
		
		return new ModelAndView(HTDA_PAGE);
	}
	
	@RequestMapping(value="/xkgl")
	public ModelAndView xkgl(){
		
		return new ModelAndView(XKGL_PAGE);
	}
	
	@RequestMapping(value="/bzjgl")
	public ModelAndView bzjgl(){
		
		return new ModelAndView(BZJGL_PAGE);
	}
	
	@RequestMapping(value="/fwsq")
	public ModelAndView fwsq(){
		
		return new ModelAndView(FWSQ_PAGE);
	}
	
	@RequestMapping(value="/sgrz")
	public ModelAndView sgrz(){
		
		return new ModelAndView(SGRZ_PAGE);
	}
	
	@RequestMapping(value="/sgjdrz")
	public ModelAndView sgjdrz(){
		
		return new ModelAndView(SGJDRZ_PAGE);
	}
	
	@RequestMapping(value="/jfRecord")
	public ModelAndView jfRecord(){
		
		return new ModelAndView(JFRECORD_PAGE);
	}
	
	@RequestMapping(value="/visitApply")
	public ModelAndView visitApply(){
		
		return new ModelAndView(VISITAPPLY_PAGE);
	}
	
	@RequestMapping(value="/feeSimulate")
	public ModelAndView feeSimulate(){
		
		return new ModelAndView(FEESIMULATE_PAGE);
	}
	
	@RequiresRoles(value = {"admin","ownership"}, logical = Logical.OR)
	@RequestMapping(value="/rlsqEdit")
	public ModelAndView rlsqEdit(){
		
		return new ModelAndView(RLSQEDIT_PAGE);
	}
	
	@RequestMapping(value="/ywdaEdit")
	public ModelAndView ywdaEdit(){
		
		return new ModelAndView(YWDAEDIT_PAGE);
	}
	
	@RequestMapping(value="/htdaEdit")
	public ModelAndView htdaEdit(){
		
		return new ModelAndView(HTDAEDIT_PAGE);
	}
	
	@RequestMapping(value="/xkglEdit")
	public ModelAndView xkglEdit(){
		
		return new ModelAndView(XKGLEDIT_PAGE);
	}
	
	@RequestMapping(value="/bzjEdit")
	public ModelAndView bzjEdit(){
		
		return new ModelAndView(BZJEDIT_PAGE);
	}
	
	@RequestMapping(value="/fwsqEdit")
	public ModelAndView fwsqEdit(){
		
		return new ModelAndView(FWSQEDIT_PAGE);
	}
	
	@RequestMapping(value="/sgjlEdit")
	public ModelAndView sgjlEdit(){
		
		return new ModelAndView(SGJLEDIT_PAGE);
	}
	
	@RequestMapping(value="/jfjlEdit")
	public ModelAndView jfjlEdit(){
		
		return new ModelAndView(JFJLEDIT_PAGE);
	}
	
	@RequestMapping(value="/gxdaEdit")
	public ModelAndView gxdaEdit(){
		
		return new ModelAndView(GXDAEDIT_PAGE);
	}
	
	@RequestMapping(value = "/acceptLoadData")
	@ResponseBody
	public Object getAcceptGrid() {
		List<CorridorIn> data = acceptService.findAccepts();
		return data;
	}
	
	@RequestMapping(value = "/finishAcceptData")
	@ResponseBody
	public Object getfinishAcceptData() {
		List<CorridorInParam> data = acceptService.findfinishAccepts();
		return data;
	}
	
	@RequestMapping(value = "/procedureLoadData")
	@ResponseBody
	public Object getProcedureGrid() {
		List<CorridorIn> data = procedureService.findProcedures();
		return data;
	}
	
	@RequestMapping(value = "/loadProcedureParam")
	@ResponseBody
	public Object loadProcedureParam() {
		List<CorridorInParam> data = procedureService.findProcedureParams();
		return data;
	}
	
	@RequestMapping(value = "/agreementLoadData")
	@ResponseBody
	public Object getAgreementGrid() {
		List<CorridorIn> data = agreementService.findAgreements();
		return data;
	}
	
	@RequestMapping(value = "/loadAgreementParam")
	@ResponseBody
	public Object loadAgreementParam() {
		List<CorridorInParam> data = agreementService.findAgreementParams();
		return data;
	}
	
	@RequestMapping(value = "/loadPayHistory")
	@ResponseBody
	public Object loadPayHistory() {
		List<PayHistory> data = payFeeService.getPayHistorys();
		return data;
	}
	
	@RequestMapping(value = "/loadPayHistoryParam")
	@ResponseBody
	public Object loadPayHistoryParam() {
		List<PayHistoryParam> data = payFeeService.getPayHistoryParams();
		return data;
	}
	
	@RequestMapping(value = "/loadCompSelect")
	@ResponseBody
	public Object getCompSelect() {
		List<CorridorIn> data = acceptService.findCompSelect();
		return data;
	}
	
	@RequestMapping(value = "/loadPTSelect")
	@ResponseBody
	public Object getPTSelect() {
		List<PipelineType> data = procedureService.findPipelineTypes();
		return data;
	}
	
	@RequestMapping(value = "/loadWSSelect")
	@ResponseBody
	public Object getWSSelect() {
		List<WarehouseSection> data = procedureService.findWarehouseSections();
		return data;
	}
	
	@RequestMapping(value = "/loadArrangeSelect")
	@ResponseBody
	public Object getArrangeSelect(@RequestParam("id") String id) {
		List<Plies> data = procedureService.findPlies(Integer.parseInt(id));
		return data;
	}
	
	@RequestMapping(value = "/loadSPileSelect")
	@ResponseBody
	public Object getSPileSelect(@RequestParam("id") String id) {
		List<PileNo> data = procedureService.findSPileNos(Integer.parseInt(id));
		return data;
	}
	
	@RequestMapping(value = "/loadEPileSelect")
	@ResponseBody
	public Object getEPileSelect(@RequestParam("id") String id) {
		List<PileNo> data = procedureService.findEPileNos(Integer.parseInt(id));
		return data;
	}
	
	@RequestMapping(value = "/loadNamberSelect")
	@ResponseBody
	public Object getNamberSelect() {
		List<Namber> data = procedureService.findNambers();
		return data;
	}
	
	@RequestMapping(value = "/loadUnpayComp")
	@ResponseBody
	public Object getUnpayComp() {
		List<CorridorOut> data = constructionService.findUnpayComp();
		return data;
	}
	
	@RequestMapping(value = "/loadOutComp")
	@ResponseBody
	public Object getOutComp() {
		List<CorridorOut> data = payFeeService.findOutComp();
		return data;
	}
	
	@RequestMapping(value = "/loadjfComp")
	@ResponseBody
	public Object getjfComp() {
		List<CorridorOut> data = payFeeService.findjfComp();
		return data;
	}
	
	@RequestMapping(value = "/loadPayNameSelect")
	@ResponseBody
	public Object getPayNameSelect() {
		List<PayName> data = payFeeService.getPayNameSelect();
		return data;
	}
	
	@RequestMapping(value = "/loadExaminedComp")
	@ResponseBody
	public Object getExaminedComp() {
		List<CorridorIn> data = agreementService.findExaminedComp();
		return data;
	}
	
	@RequestMapping(value = "/loadOverComp")
	@ResponseBody
	public Object getOverComp() {
		List<CorridorIn> data = constructionService.findOverComp();
		return data;
	}
	
	@RequestMapping(value = "/loadFinishComp")
	@ResponseBody
	public Object getFinishComp() {
		List<CorridorOut> data = constructionService.findFinishComp();
		return data;
	}
	
	@RequestMapping(value = "/loadPipelineArchives")
	@ResponseBody
	public Object getPipelineArchives(@RequestParam("comp") String comp) throws UnsupportedEncodingException {
		String name = URLDecoder.decode(comp, "UTF-8");
		List<PipelineArchives> data = constructionService.findPipelineArchives(name);
		return data;
	}
	
	@RequestMapping(value = "/loadConType")
	@ResponseBody
	public Object getConType() {
		List<ConstructionType> data = constructionService.findConType();
		return data;
	}
	
	@RequestMapping(value = "/loadServiceType")
	@ResponseBody
	public Object getServiceType() {
		List<ServiceType> data = constructionService.findServiceType();
		return data;
	}
	
	@RequestMapping(value = "/loadDeductStandard")
	@ResponseBody
	public Object getDeductStandard() {
		List<DeductStandard> data = constructionService.findDeductStandard();
		return data;
	}
	
	@RequestMapping(value = "/loadConstructionGrid")
	@ResponseBody
	public Object getConstructionGrid() {
		List<ConstructionManage> data = constructionService.findConManageGrid();
		return data;
	}
	
	@RequestMapping(value = "/loadServiceGrid")
	@ResponseBody
	public Object getServiceGrid() {
		List<ServiceApplication> data = constructionService.findServiceApplication();
		return data;
	}
	
	@RequestMapping(value = "/loadServiceParam")
	@ResponseBody
	public Object getServiceParam() {
		List<ServiceApplicationParam> data = constructionService.findServiceParam();
		return data;
	}
	
	@RequestMapping(value = "/loadBondGrid")
	@ResponseBody
	public Object getBondGrid() {
		List<CorridorOut> data = constructionService.findBondGrid();
		return data;
	}
	
	@RequestMapping(value = "/loadBondParam")
	@ResponseBody
	public Object getBondParam() {
		List<CorridorOutParam> data = constructionService.findBondParam();
		return data;
	}
	
	@RequestMapping(value = "/loadConstructionLog")
	@ResponseBody
	public Object getConstructionLog() {
		List<ConstructionLog> data = constructionService.findConstructionLog();
		return data;
	}
	
	@RequestMapping(value = "/loadSupervisionLog")
	@ResponseBody
	public Object getSupervisionLog() {
		List<SupervisionLog> data = constructionService.findSupervisionLog();
		return data;
	}
	
	@RequestMapping(value = "/loadConstructionLogParam")
	@ResponseBody
	public Object getConstructionLogParam() {
		List<ConstructionLogParam> data = constructionService.getConstructionLog();
		return data;
	}
	
	@RequestMapping(value = "/deductList")
	@ResponseBody
	public Object getdeductList(@RequestParam("coId") String coId) {
		List<DeductStandard> data = constructionService.findDeductListById(Integer.parseInt(coId));
		return data;
	}
	
	@RequestMapping(value = "/findVisitApply")
	@ResponseBody
	public Object getVisitApply(@RequestParam("rows")int rows,@RequestParam("page")int page) {
		VisitApplyPage pages = new VisitApplyPage();
		List<VisitApply> data = procedureService.findVisitApply();
		int rowCount = 0;
		if(data.size()%rows==0){
			rowCount = data.size()/rows;
		}else{
			rowCount = data.size()/rows+1;
		}
		List<VisitApply> cdata = new ArrayList<VisitApply>();
		for(int i=0;i<rows;i++){
			if(i+rows*(page-1)<data.size()){
			cdata.add(data.get(i+rows*(page-1)));
			}
		}
		pages.setPage(page);
		pages.setRecords(data.size());
		pages.setTotal(rowCount);
		pages.setRows(cdata);
		return pages;
	}
	
	@RequestMapping(value="/operVisitApply")
	public void operVisitApply(@ModelAttribute VisitApply va,@RequestParam("oper") String oper){
		
		if("add".equals(oper.toString())){
			va.setApplyTime(nsdf.format(new Date()));
			procedureService.addVisitApply(va);
			
		}else if("edit".equals(oper.toString())){
			procedureService.updateVisitApply(va);
			
		}else if("del".equals(oper.toString())){
			String id;
			if(va.getId().contains(",")){
			  	id = va.getId().replace(',', ' ').trim();
			}else{
				id = va.getId();
			}
			procedureService.deleteVisitApply(Integer.parseInt(id));
		}
		
	}
	
	@RequestMapping(value="/addAccept")
	public ModelAndView addAccept(@RequestParam("CompName") String CompName,@RequestParam("CallNo") String CallNo,@RequestParam("Contactor") String Contactor,@RequestParam("builderName") String builderName,@RequestParam("PType") String PType,@RequestParam("sIntroduction") String sIntroduction,@RequestParam("eIntroduction") String eIntroduction){
		   
           CorridorIn corridorIn = new CorridorIn();
		   corridorIn.setName(CompName);
		   corridorIn.setPhoneNum(CallNo);
		   corridorIn.setContactor(Contactor);
		   corridorIn.setPt_id(PType);
		   corridorIn.setBuilderName(builderName);
		   corridorIn.setSws_id(sIntroduction);
		   corridorIn.setEws_id(eIntroduction);
		   corridorIn.setCreateTime(new Timestamp(new Date().getTime()));
 		   corridorIn.setStatus("2");
 		   acceptService.addAccept(corridorIn);
		   return new ModelAndView(SQBRECORD_PAGE);
 		   
	}
	
	@RequestMapping(value="/updateAccept")
	public ModelAndView updateAccept(@RequestParam("compId") String compId,@RequestParam("fileField") MultipartFile fileField,HttpServletRequest req){
		
		String savePath =  SAVE_PATH+"acceptApplicationIn";
        File file = new File(savePath);
        if (!file.exists() && !file.isDirectory()) {
            //创建目录
            file.mkdir();
       }
        String fileType = fileField.getContentType();
        String filename = fileField.getOriginalFilename();
           CorridorIn corridorIn = new CorridorIn();
           corridorIn.setId(Integer.parseInt(compId));
        if("application/vnd.openxmlformats-officedocument.wordprocessingml.document".equals(fileType) || "application/msword".equals(fileType) || "application/pdf".equals(fileType) || "image/jpeg".equals(fileType)){
        	filename = filename.substring(filename.lastIndexOf("\\")+1);
        	try {
				InputStream in = fileField.getInputStream();
				FileOutputStream out = new FileOutputStream(savePath + "\\" + filename);
				//创建一个缓冲区
			    byte buffer[] = new byte[1024];
			    //判断输入流中的数据是否已经读完的标识
				int len = 0;
				 while((len=in.read(buffer))>0){
					//使用FileOutputStream输出流将缓冲区的数据写入到指定的目录(savePath + "\\" + filename)当中
					out.write(buffer, 0, len);
					 }
					//关闭输入流
					in.close();
					//关闭输出流
					out.close();
			} catch (IOException e) {
				
				e.printStackTrace();
			}
 		   corridorIn.setAcceptApplication(filename);
 		   corridorIn.setStatus("2");
 		  acceptService.updateAccept(corridorIn);
 		}
        return new ModelAndView(SQBRECORD_PAGE);  
		   
	}
	
	@RequestMapping(value="/updateAcceptFile")
	public ModelAndView updateAcceptFile(@RequestParam("id") int id,@RequestParam("acceptApplication") MultipartFile acceptApplication,HttpServletRequest req){
		
		String savePath =  SAVE_PATH+"acceptApplicationIn";
        File file = new File(savePath);
        if (!file.exists() && !file.isDirectory()) {
            //创建目录
            file.mkdir();
       }
        String fileType = acceptApplication.getContentType();
        String filename = acceptApplication.getOriginalFilename();
           CorridorIn corridorIn = new CorridorIn();
           corridorIn.setId(id);
        if("application/vnd.openxmlformats-officedocument.wordprocessingml.document".equals(fileType) || "application/msword".equals(fileType) || "application/pdf".equals(fileType) || "image/jpeg".equals(fileType)){
        	filename = filename.substring(filename.lastIndexOf("\\")+1);
        	try {
				InputStream in = acceptApplication.getInputStream();
				FileOutputStream out = new FileOutputStream(savePath + "\\" + filename);
				//创建一个缓冲区
			    byte buffer[] = new byte[1024];
			    //判断输入流中的数据是否已经读完的标识
				int len = 0;
				 while((len=in.read(buffer))>0){
					//使用FileOutputStream输出流将缓冲区的数据写入到指定的目录(savePath + "\\" + filename)当中
					out.write(buffer, 0, len);
					 }
					//关闭输入流
					in.close();
					//关闭输出流
					out.close();
			} catch (IOException e) {
				
				e.printStackTrace();
			}
        	corridorIn.setStatus("2");
 		   corridorIn.setAcceptApplication(filename);
 		  acceptService.updateAccept(corridorIn);
 		}
        return new ModelAndView(RLSQEDIT_PAGE);  
		   
	}
	
	@RequestMapping(value="/finishAcceptEdit")
	@ResponseBody
	public Object finishAcceptEdit(@ModelAttribute CorridorInParam corridorInParam){
		if("edit".equals(corridorInParam.getOper())){
			acceptService.modifyAccept(corridorInParam);
		}
		else{
			acceptService.deleteAccpet(corridorInParam.getId());
		}
		return corridorInParam.getId();
	}
	
	@RequiresRoles(value = {"admin","operator"}, logical = Logical.OR)
	@RequestMapping(value="/pipeLineUpdate")
	public ModelAndView pipeLineUpdate(@ModelAttribute PipelineInfoParam plInfo) throws Throwable{
		CorridorIn corridorIn = new CorridorIn();
		PipelineInfo pipelineInfo = new PipelineInfo();
		corridorIn.setId(plInfo.getComp());
		corridorIn.setStatus("3");
		pipelineInfo.setIn_id(plInfo.getComp());
		pipelineInfo.setMessage(plInfo.getMessage());
		pipelineInfo.setStartTime(new Timestamp(sdf.parse(plInfo.getStartTime()).getTime()));
		pipelineInfo.setEndTime(new Timestamp(sdf.parse(plInfo.getEndTime()).getTime()));
		pipelineInfo.setPNum(plInfo.getPNum());
		pipelineInfo.setmArea(plInfo.getmArea());
		pipelineInfo.setmMashine(plInfo.getmMashine());
		pipelineInfo.setPcharge(plInfo.getPcharge());
		pipelineInfo.setPhoneCall(plInfo.getPhoneCall());
		pipelineInfo.setP_id(plInfo.getArrangement());
		pipelineInfo.setSpn_id(plInfo.getsPile());
		pipelineInfo.setSn_id(plInfo.getsHole());
		pipelineInfo.setEpn_id(plInfo.getePile());
		pipelineInfo.setEn_id(plInfo.geteHole());
		if(procedureService.pipelineInfoExist(plInfo.getComp())==0){
		procedureService.updatePipeline(corridorIn,pipelineInfo);
		}
		return new ModelAndView(YWDA_PAGE);
	}
	
	@RequiresRoles(value = {"admin","operator","ownership","regulator","constructionSector","projectManager"}, logical = Logical.OR)
	@RequestMapping(value="/pipeLineUpdate2")
	public ModelAndView pipeLineUpdate2(@RequestParam("compId")int compId) throws Throwable{
		Subject currentUser = SecurityUtils.getSubject();
		ShiroUser shiroUser = (ShiroUser)currentUser.getPrincipal();
		Role role = userService.getUserRole(shiroUser.getId());
		PipelineInfo pli = procedureService.findPipelineInfoById(compId);
		CorridorIn ci = constructionService.findCorridorInById(compId);
		String flag = "0"; 
		if("1".equals(ci.getOwnershipOk())&&"1".equals(ci.getRegulatorOk())&&"1".equals(ci.getConstructionSectorOk())&&"1".equals(ci.getProjectManagerOk())){
			flag="1";
		}
		return new ModelAndView(FAYZ_PAGE)
		.addObject("compId", compId)
		.addObject("sIntroduction", pli.getsIntroduction())
		.addObject("sPile", pli.getsPile())
		.addObject("sHole", pli.getsHole())
		.addObject("eIntroduction", pli.geteIntroduction())
		.addObject("ePile", pli.getePile())
		.addObject("eHole", pli.geteHole())
		.addObject("role",role.getDescription())
		.addObject("flag", flag)
		.addObject("pipeId", pli.getP_id())
		.addObject("sfileFiled1", ci.getfileFiled1())
		.addObject("sfileFiled2", ci.getfileFiled2())
		.addObject("sfileFiled3", ci.getfileFiled3());
	}
	
	@RequestMapping(value="/ownershipConfirm")
	public void ownershipConfirm(@RequestParam("compId") String compId){
		constructionService.updateOwnership(Integer.parseInt(compId));
	}
	
	@RequestMapping(value="/regulatorConfirm")
	public void regulatorConfirm(@RequestParam("compId") String compId){
		constructionService.updateregulator(Integer.parseInt(compId));
	}
	
	@RequestMapping(value="/constructionSectorConfirm")
	public void constructionSectorConfirm(@RequestParam("compId") String compId){
		constructionService.updateconstructionSector(Integer.parseInt(compId));
	}
	
	@RequestMapping(value="/projectManagerConfirm")
	public void projectManagerConfirm(@RequestParam("compId") String compId){
		constructionService.updateprojectManager(Integer.parseInt(compId));
	}

	//方案验证增加上传
	@RequestMapping(value = "/fayzfield1Upload")
	public void fayzfield1Upload(@RequestParam("compId") String compId,@RequestParam("fileField1") MultipartFile fileField,HttpServletRequest req){
		String savePath =  SAVE_PATH+"fayzIn";
		File file = new File(savePath);
		if (!file.exists() && !file.isDirectory()) {
			//创建目录
			file.mkdir();
		}
		String fileType = fileField.getContentType();
		String filename = fileField.getOriginalFilename();
		if("application/vnd.openxmlformats-officedocument.wordprocessingml.document".equals(fileType) || "application/msword".equals(fileType) || "application/pdf".equals(fileType) || "image/jpeg".equals(fileType)){
			filename = filename.substring(filename.lastIndexOf("\\")+1);
			try {
				InputStream in = fileField.getInputStream();
				FileOutputStream out = new FileOutputStream(savePath + "\\" + filename);
				//创建一个缓冲区
				byte buffer[] = new byte[1024];
				//判断输入流中的数据是否已经读完的标识
				int len = 0;
				while((len=in.read(buffer))>0){
					//使用FileOutputStream输出流将缓冲区的数据写入到指定的目录(savePath + "\\" + filename)当中
					out.write(buffer, 0, len);
				}
				//关闭输入流
				in.close();
				//关闭输出流
				out.close();
			} catch (IOException e) {

				e.printStackTrace();
			}
			CorridorIn corridorIn = new CorridorIn();
			corridorIn.setId(Integer.parseInt(compId));
			corridorIn.setfileFiled1(filename);
			constructionService.updatefileField1(corridorIn);
		}
		//return new ModelAndView(FAYZ_PAGE);
	}

	@RequestMapping(value = "/fayzfield2Upload")
	public void fayzfield2Upload(@RequestParam("compId") String compId,@RequestParam("fileField2") MultipartFile fileField,HttpServletRequest req){
		String spath = Thread.currentThread().getContextClassLoader()
				.getResource("/").getPath();
		spath = spath.substring(0,spath.lastIndexOf("/"));
		spath = spath.substring(0,spath.lastIndexOf("/"));
		spath = spath.substring(0,spath.lastIndexOf("/"));
		String savePath =  spath + "/resources/UploadFiles/fayzImages";
		File file = new File(savePath);
		if (!file.exists() && !file.isDirectory()) {
			//创建目录
			file.mkdir();
		}
		String fileType = fileField.getContentType();
		//String filename = fileField.getOriginalFilename();
		String pic_time = new  SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
		/* 从当时时间MD5强制重命名图片*/
		if(fileType.equals("image/jpeg")){
			pic_time =   pic_time.concat(".jpg");
		} else if (fileType.equals("image/png")){
			pic_time = pic_time.concat(".png");
		} else if(fileType.equals("image/bmp")){
			pic_time =  pic_time.concat(".bmp");
		} else if(fileType.equals("image/gif")){
			pic_time = pic_time.concat(".gif");
		} else pic_time = pic_time.concat(".jpg");
		if("image/jpg".equals(fileType) || "image/gif".equals(fileType) || "image/png".equals(fileType) || "image/jpeg".equals(fileType)){



			//filename = filename.substring(filename.lastIndexOf("\\")+1);
			try {
				InputStream in = fileField.getInputStream();
				FileOutputStream out = new FileOutputStream(savePath + "\\" + pic_time);
				//创建一个缓冲区
				byte buffer[] = new byte[1024];
				//判断输入流中的数据是否已经读完的标识
				int len = 0;
				while((len=in.read(buffer))>0){
					//使用FileOutputStream输出流将缓冲区的数据写入到指定的目录(savePath + "\\" + filename)当中
					out.write(buffer, 0, len);
				}
				//关闭输入流
				in.close();
				//关闭输出流
				out.close();
			} catch (IOException e) {

				e.printStackTrace();
			}
			CorridorIn corridorIn = new CorridorIn();
			corridorIn.setId(Integer.parseInt(compId));
			corridorIn.setfileFiled2(pic_time);
			constructionService.updatefileField2(corridorIn);
		}
	}

	@RequestMapping(value = "/fayzfield3Upload")
	public void fayzfield3Upload(@RequestParam("compId") String compId,@RequestParam("fileField3") MultipartFile fileField,HttpServletRequest req){
		String spath = Thread.currentThread().getContextClassLoader()
				.getResource("/").getPath();
		spath = spath.substring(0,spath.lastIndexOf("/"));
		spath = spath.substring(0,spath.lastIndexOf("/"));
		spath = spath.substring(0,spath.lastIndexOf("/"));
		String savePath =  spath + "/resources/UploadFiles/fayzImages";
		File file = new File(savePath);
		if (!file.exists() && !file.isDirectory()) {
			//创建目录
			file.mkdir();
		}
		String fileType = fileField.getContentType();
		//String filename = fileField.getOriginalFilename();
		String pic_time = new  SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
		/* 从当时时间MD5强制重命名图片*/
		if(fileType.equals("image/jpeg")){
			pic_time =   pic_time.concat(".jpg");
		} else if (fileType.equals("image/png")){
			pic_time = pic_time.concat(".png");
		} else if(fileType.equals("image/bmp")){
			pic_time =  pic_time.concat(".bmp");
		} else if(fileType.equals("image/gif")){
			pic_time = pic_time.concat(".gif");
		} else pic_time = pic_time.concat(".jpg");
		if("image/jpg".equals(fileType) || "image/gif".equals(fileType) || "image/png".equals(fileType) || "image/jpeg".equals(fileType)){
			//filename = filename.substring(filename.lastIndexOf("\\")+1);
			try {
				InputStream in = fileField.getInputStream();
				FileOutputStream out = new FileOutputStream(savePath + "\\" + pic_time);
				//创建一个缓冲区
				byte buffer[] = new byte[1024];
				//判断输入流中的数据是否已经读完的标识
				int len = 0;
				while((len=in.read(buffer))>0){
					//使用FileOutputStream输出流将缓冲区的数据写入到指定的目录(savePath + "\\" + filename)当中
					out.write(buffer, 0, len);
				}
				//关闭输入流
				in.close();
				//关闭输出流
				out.close();
			} catch (IOException e) {

				e.printStackTrace();
			}
			CorridorIn corridorIn = new CorridorIn();
			corridorIn.setId(Integer.parseInt(compId));
			corridorIn.setfileFiled3(pic_time);
			constructionService.updatefileField3(corridorIn);
		}
	}

	@RequiresRoles(value = {"admin","operator"}, logical = Logical.OR)
	@RequestMapping(value="/verifyPass")
	public ModelAndView verifyPass(@RequestParam("compId") String compId){
		if(!compId.isEmpty()){
		Subject currentUser = SecurityUtils.getSubject();
		ShiroUser shiroUser = (ShiroUser)currentUser.getPrincipal();
		CorridorIn corridorIn = new CorridorIn();
		corridorIn.setId(Integer.parseInt(compId));
		corridorIn.setStatus("6");
		corridorIn.setBusinessManager(shiroUser.getLoginName());
		corridorIn.setProcedureTime(new Timestamp(new Date().getTime()));
		procedureService.updateSigned(corridorIn);
		}
		return new ModelAndView(YWDA_PAGE);
	}
	
	@RequiresRoles(value = {"admin","ownership"}, logical = Logical.OR)
	@RequestMapping(value="/examineUpload")
	public ModelAndView examineUpload(@RequestParam("compId") String compId,@RequestParam("fileField") MultipartFile fileField,HttpServletRequest req){
		String savePath =  SAVE_PATH+"examineIn";
        File file = new File(savePath);
        if (!file.exists() && !file.isDirectory()) {
            //创建目录
            file.mkdir();
       }
        String fileType = fileField.getContentType();
        String filename = fileField.getOriginalFilename();
        if("application/vnd.openxmlformats-officedocument.wordprocessingml.document".equals(fileType) || "application/msword".equals(fileType) || "application/pdf".equals(fileType) || "image/jpeg".equals(fileType)){
        	filename = filename.substring(filename.lastIndexOf("\\")+1);
        	try {
				InputStream in = fileField.getInputStream();
				FileOutputStream out = new FileOutputStream(savePath + "\\" + filename);
				//创建一个缓冲区
			    byte buffer[] = new byte[1024];
			    //判断输入流中的数据是否已经读完的标识
				int len = 0;
				 while((len=in.read(buffer))>0){
					//使用FileOutputStream输出流将缓冲区的数据写入到指定的目录(savePath + "\\" + filename)当中
					out.write(buffer, 0, len);
					 }
					//关闭输入流
					in.close();
					//关闭输出流
					out.close();
			} catch (IOException e) {
				
				e.printStackTrace();
			}
        	Subject currentUser = SecurityUtils.getSubject();
    		ShiroUser shiroUser = (ShiroUser)currentUser.getPrincipal();
    		
			CorridorIn corridorIn = new CorridorIn();
			corridorIn.setId(Integer.parseInt(compId));
			corridorIn.setStatus("6");
			corridorIn.setExamineTable(filename);
			corridorIn.setFileUploadPeople(shiroUser.getLoginName());
			corridorIn.setProcedureTime(new Timestamp(new Date().getTime()));
			procedureService.updateExamine(corridorIn);
        }
		return new ModelAndView(YWDA_PAGE);
	}
	
	@RequestMapping(value="/procedureEdit")
	@ResponseBody
	public Object procedureEdit(@ModelAttribute CorridorInParam corridorInParam){
		if("del".equals(corridorInParam.getOper())){
			acceptService.deleteAccpet(corridorInParam.getId());
			return corridorInParam.getId();
		}else{
		String acceptApplication = procedureService.getAcceptApplicationById(corridorInParam.getId());
		if(acceptApplication==null){
			return "";
		}else{
			return corridorInParam.getId();
		}
		}
		
	}
	
	@RequestMapping(value="/updateProcedureFile")
	public ModelAndView updateProcedureFile(@RequestParam("id") int id,@RequestParam("examineTable") MultipartFile examineTable,HttpServletRequest req){
		
		String savePath =  SAVE_PATH+"examineIn";
        File file = new File(savePath);
        if (!file.exists() && !file.isDirectory()) {
            //创建目录
            file.mkdir();
       }
        String fileType = examineTable.getContentType();
        String filename = examineTable.getOriginalFilename();
           CorridorIn corridorIn = new CorridorIn();
           corridorIn.setId(id);
        if("application/vnd.openxmlformats-officedocument.wordprocessingml.document".equals(fileType) || "application/msword".equals(fileType) || "application/pdf".equals(fileType) || "image/jpeg".equals(fileType)){
        	filename = filename.substring(filename.lastIndexOf("\\")+1);
        	try {
				InputStream in = examineTable.getInputStream();
				FileOutputStream out = new FileOutputStream(savePath + "\\" + filename);
				//创建一个缓冲区
			    byte buffer[] = new byte[1024];
			    //判断输入流中的数据是否已经读完的标识
				int len = 0;
				 while((len=in.read(buffer))>0){
					//使用FileOutputStream输出流将缓冲区的数据写入到指定的目录(savePath + "\\" + filename)当中
					out.write(buffer, 0, len);
					 }
					//关闭输入流
					in.close();
					//关闭输出流
					out.close();
			} catch (IOException e) {
				
				e.printStackTrace();
			}
 		   corridorIn.setExamineTable(filename);
 		  procedureService.updateProcedureFile(corridorIn);
 		}
        return new ModelAndView(YWDAEDIT_PAGE);  
		   
	}
	
	@RequestMapping(value="/agreementUpdate")
	public ModelAndView agreementUpdate(@RequestParam("Comp") String Comp) throws Throwable{
		
        	Subject currentUser = SecurityUtils.getSubject();
    		ShiroUser shiroUser = (ShiroUser)currentUser.getPrincipal();
			CorridorIn corridorIn = new CorridorIn();
			corridorIn.setId(Integer.parseInt(Comp));
			corridorIn.setStatus("7");
			corridorIn.setOperatePeople(shiroUser.getLoginName());
			corridorIn.setOperateUpdateTime(new Timestamp(new Date().getTime()));
			
			CorridorOut corridorOut = new CorridorOut();
			corridorOut.setStatus("1");
			corridorOut.setCreateTime(new Timestamp(new Date().getTime()));
			corridorOut.setIn_ID(Integer.parseInt(Comp));
			procedureService.updateAgreement(corridorIn, corridorOut);
        
		return new ModelAndView(HTDA_PAGE);
	}
	
	@RequestMapping(value="/AgreementEdit")
	@ResponseBody
	public Object AgreementEdit(@ModelAttribute CorridorInParam corridorInParam){
		if("del".equals(corridorInParam.getOper())){
			acceptService.deleteAccpet(corridorInParam.getId());
		}
		return corridorInParam.getId();
	}
	
	@RequestMapping(value="/updateAgreement")
	public ModelAndView updateAgreement(@RequestParam("id") int id,@RequestParam("agreement") MultipartFile agreement,HttpServletRequest req){
		
		String savePath =  SAVE_PATH+"agreementIn";
        File file = new File(savePath);
        if (!file.exists() && !file.isDirectory()) {
            //创建目录
            file.mkdir();
       }
        String fileType = agreement.getContentType();
        String filename = agreement.getOriginalFilename();
           CorridorIn corridorIn = new CorridorIn();
           corridorIn.setId(id);
        if("application/vnd.openxmlformats-officedocument.wordprocessingml.document".equals(fileType) || "application/msword".equals(fileType) || "application/pdf".equals(fileType) || "image/jpeg".equals(fileType)){
        	filename = filename.substring(filename.lastIndexOf("\\")+1);
        	try {
				InputStream in = agreement.getInputStream();
				FileOutputStream out = new FileOutputStream(savePath + "\\" + filename);
				//创建一个缓冲区
			    byte buffer[] = new byte[1024];
			    //判断输入流中的数据是否已经读完的标识
				int len = 0;
				 while((len=in.read(buffer))>0){
					//使用FileOutputStream输出流将缓冲区的数据写入到指定的目录(savePath + "\\" + filename)当中
					out.write(buffer, 0, len);
					 }
					//关闭输入流
					in.close();
					//关闭输出流
					out.close();
			} catch (IOException e) {
				
				e.printStackTrace();
			}
 		   corridorIn.setAgreement(filename);
 		  agreementService.updateAgreementFile(corridorIn);
 		}
        return new ModelAndView(HTDA_PAGE);  
		   
	}
	
	@RequestMapping(value="/updateAgreementFile")
	public ModelAndView updateAgreementFile(@RequestParam("id") int id,@RequestParam("agreement") MultipartFile agreement,HttpServletRequest req){
		
		String savePath =  SAVE_PATH+"agreementIn";
        File file = new File(savePath);
        if (!file.exists() && !file.isDirectory()) {
            //创建目录
            file.mkdir();
       }
        String fileType = agreement.getContentType();
        String filename = agreement.getOriginalFilename();
           CorridorIn corridorIn = new CorridorIn();
           corridorIn.setId(id);
        if("application/vnd.openxmlformats-officedocument.wordprocessingml.document".equals(fileType) || "application/msword".equals(fileType) || "application/pdf".equals(fileType) || "image/jpeg".equals(fileType)){
        	filename = filename.substring(filename.lastIndexOf("\\")+1);
        	try {
				InputStream in = agreement.getInputStream();
				FileOutputStream out = new FileOutputStream(savePath + "\\" + filename);
				//创建一个缓冲区
			    byte buffer[] = new byte[1024];
			    //判断输入流中的数据是否已经读完的标识
				int len = 0;
				 while((len=in.read(buffer))>0){
					//使用FileOutputStream输出流将缓冲区的数据写入到指定的目录(savePath + "\\" + filename)当中
					out.write(buffer, 0, len);
					 }
					//关闭输入流
					in.close();
					//关闭输出流
					out.close();
			} catch (IOException e) {
				
				e.printStackTrace();
			}
 		   corridorIn.setAgreement(filename);
 		  agreementService.updateAgreementFile(corridorIn);
 		}
        return new ModelAndView(HTDAEDIT_PAGE);  
		   
	}
	
	@RequestMapping(value="/jfRecordUpload")
	public ModelAndView jfRecordUpload(@RequestParam("Comp") String Comp,@RequestParam("payName") String payName,@RequestParam("balance") String balance,@RequestParam("feeFile") MultipartFile feeFile,HttpServletRequest req){
		if(Comp!=null&&payName!=null&&balance!=null&&feeFile!=null){
			String savePath =  SAVE_PATH+"paymentVoucher";
                 File file = new File(savePath);
                 //判断上传文件的保存目录是否存在
                if (!file.exists() && !file.isDirectory()) {
                     //创建目录
                     file.mkdir();
                }
            String fileType = feeFile.getContentType();
            if("application/vnd.openxmlformats-officedocument.wordprocessingml.document".equals(fileType) || "application/msword".equals(fileType) || "application/pdf".equals(fileType) || "image/jpeg".equals(fileType)){
            String fileName = feeFile.getOriginalFilename();
            try {
				InputStream in = feeFile.getInputStream();
				FileOutputStream out = new FileOutputStream(savePath + "\\" + fileName);
				//创建一个缓冲区
			    byte buffer[] = new byte[1024];
			    //判断输入流中的数据是否已经读完的标识
				int len = 0;
				 while((len=in.read(buffer))>0){
					//使用FileOutputStream输出流将缓冲区的数据写入到指定的目录(savePath + "\\" + filename)当中
					out.write(buffer, 0, len);
					 }
					//关闭输入流
					in.close();
					//关闭输出流
					out.close();
			} catch (IOException e) {
				
				e.printStackTrace();
			}
            
            PayHistory payHistory = new PayHistory();
			payHistory.setIn_ID(Integer.parseInt(Comp));
			payHistory.setPayType(Integer.parseInt(payName));
			payHistory.setPayCost(Double.parseDouble(balance));
			payHistory.setPayVoucher(fileName);
			payHistory.setOperater("admin");
			payHistory.setCreateTime(new Timestamp(new Date().getTime()));
			payFeeService.updatePay(payHistory);
            }
			
		}
		return new ModelAndView(JFRECORD_PAGE);
	}
	
	@RequestMapping(value="/jfRecordEdit")
	@ResponseBody
	public Object jfRecordEdit(@ModelAttribute PayHistory payHistory){
		if("edit".equals(payHistory.getOper())){
			payFeeService.updatePayFee(payHistory);
		}
		else{
			payFeeService.deletePayHistory(payHistory.getId());
		}
		return payHistory.getId();
	}
	
	
	@RequestMapping(value="/deleteConstructionLog")
	@ResponseBody
	public Object deleteConstructionLog(@ModelAttribute ConstructionLog constructionLog)throws Throwable{
		if("del".equals(constructionLog.getOper())){
			constructionService.deleteConstructionLog(constructionLog.getId());
		}
		return constructionLog.getId();
	}
	
	@RequestMapping(value="/deleteConstructionManage")
	@ResponseBody
	public Object deleteConstructionManage(@ModelAttribute ConstructionManage constructionManage)throws Throwable{
		if("del".equals(constructionManage.getOper())){
			constructionService.deleteConstructionManage(constructionManage.getId());
		}
		return constructionManage.getId();
	}
	
	@RequestMapping(value="/deleteServiceApplication")
	@ResponseBody
	public Object deleteServiceApplication(@ModelAttribute ServiceApplication serviceApplication)throws Throwable{
		if("del".equals(serviceApplication.getOper())){
			constructionService.deleteServiceApplication(serviceApplication.getId());
		}
		return serviceApplication.getId();
	}
	
	@RequestMapping(value="/deleteBond")
	@ResponseBody
	public Object deleteBond(@ModelAttribute CorridorOut corridorOut)throws Throwable{
		if("del".equals(corridorOut.getOper())){
			constructionService.deleteBond(corridorOut.getId());
		}
		return corridorOut.getId();
	}
	
	@RequestMapping(value="/conPermitUpload")
	public ModelAndView conPermitUpload(@RequestParam("Comp") String Comp,@RequestParam("conType") String conType,@RequestParam("fireSafetyFile") MultipartFile fireSafetyFile,@RequestParam("constructionSafetyFile") MultipartFile constructionSafetyFile,@RequestParam("safetyProductionAgreementFile") MultipartFile safetyProductionAgreementFile,HttpServletRequest req) throws Throwable{
		String savePath1 =  SAVE_PATH+"fireSafety";
		File file1 = new File(savePath1);
		if (!file1.exists() && !file1.isDirectory()) {
            //创建目录
            file1.mkdir();
       }
		String fileType1 = fireSafetyFile.getContentType();
		String fileName1 = "";
		if("application/vnd.openxmlformats-officedocument.wordprocessingml.document".equals(fileType1) || "application/msword".equals(fileType1) || "application/pdf".equals(fileType1) || "image/jpeg".equals(fileType1)){
			fileName1 = fireSafetyFile.getOriginalFilename();
			try {
				InputStream in1 = fireSafetyFile.getInputStream();
				FileOutputStream out1 = new FileOutputStream(savePath1 + "\\" + fileName1);
				//创建一个缓冲区
			    byte buffer1[] = new byte[1024];
			    //判断输入流中的数据是否已经读完的标识
				int len = 0;
				 while((len=in1.read(buffer1))>0){
					//使用FileOutputStream输出流将缓冲区的数据写入到指定的目录(savePath + "\\" + filename)当中
					out1.write(buffer1, 0, len);
					 }
					//关闭输入流
					in1.close();
					//关闭输出流
					out1.close();
			} catch (IOException e) {
				
				e.printStackTrace();
			}
			
		}
		
		String savePath2 =  SAVE_PATH+"constructionSafety";
		File file2 = new File(savePath2);
		if (!file2.exists() && !file2.isDirectory()) {
            //创建目录
            file2.mkdir();
       }
		String fileType2 = constructionSafetyFile.getContentType();
		String fileName2 = "";
		if("application/vnd.openxmlformats-officedocument.wordprocessingml.document".equals(fileType2) || "application/msword".equals(fileType2) || "application/pdf".equals(fileType2) || "image/jpeg".equals(fileType2)){
			fileName2 = constructionSafetyFile.getOriginalFilename();
			try {
				InputStream in2 = constructionSafetyFile.getInputStream();
				FileOutputStream out2 = new FileOutputStream(savePath2 + "\\" + fileName2);
				//创建一个缓冲区
			    byte buffer2[] = new byte[1024];
			    //判断输入流中的数据是否已经读完的标识
				int len = 0;
				 while((len=in2.read(buffer2))>0){
					//使用FileOutputStream输出流将缓冲区的数据写入到指定的目录(savePath + "\\" + filename)当中
					out2.write(buffer2, 0, len);
					 }
					//关闭输入流
					in2.close();
					//关闭输出流
					out2.close();
			} catch (IOException e) {
				
				e.printStackTrace();
			}
			
		}
		
		String savePath3 =  SAVE_PATH+"safetyProductionAgreement";
		File file3 = new File(savePath3);
		if (!file3.exists() && !file3.isDirectory()) {
            //创建目录
            file3.mkdir();
       }
		String fileType3 = safetyProductionAgreementFile.getContentType();
		String fileName3 = "";
		if("application/vnd.openxmlformats-officedocument.wordprocessingml.document".equals(fileType3) || "application/msword".equals(fileType3) || "application/pdf".equals(fileType3) || "image/jpeg".equals(fileType3)){
			fileName3 = safetyProductionAgreementFile.getOriginalFilename();
			try {
				InputStream in3 = safetyProductionAgreementFile.getInputStream();
				FileOutputStream out3 = new FileOutputStream(savePath3 + "\\" + fileName3);
				//创建一个缓冲区
			    byte buffer3[] = new byte[1024];
			    //判断输入流中的数据是否已经读完的标识
				int len = 0;
				 while((len=in3.read(buffer3))>0){
					//使用FileOutputStream输出流将缓冲区的数据写入到指定的目录(savePath + "\\" + filename)当中
					out3.write(buffer3, 0, len);
					 }
					//关闭输入流
					in3.close();
					//关闭输出流
					out3.close();
			} catch (IOException e) {
				
				e.printStackTrace();
			}
			
		}
		ConstructionManage constructionManage = new ConstructionManage();
		constructionManage.setIn_ID(Integer.parseInt(Comp));
		constructionManage.setCtype_id(Integer.parseInt(conType));
		constructionManage.setFireSafety(fileName1);
		constructionManage.setConstructionSafety(fileName2);
		constructionManage.setSafetyProductionAgreement(fileName3);
		constructionManage.setOperator("admin");
		constructionService.addConstructionManage(constructionManage);
		
		return new ModelAndView(XKGL_PAGE);
	}
	
	@RequestMapping(value="/serviceUpload")
	public ModelAndView serviceUpload(@RequestParam("Comp") String Comp,@RequestParam("serType") String serType,@RequestParam("serviceFile") MultipartFile serviceFile,HttpServletRequest req) throws Throwable{
		String savePath = "";
		if("1".equals(serType)){
			savePath = SAVE_PATH+"electroApp";
		}
		else if("2".equals(serType)){
			savePath = SAVE_PATH+"hotWork";
		}
		else if("3".equals(serType)){
			savePath = SAVE_PATH+"dismantleMove";
		}
        File file = new File(savePath);
        //判断上传文件的保存目录是否存在
       if (!file.exists() && !file.isDirectory()) {
            //创建目录
            file.mkdir();
       }
   String fileType = serviceFile.getContentType();
   if("application/vnd.openxmlformats-officedocument.wordprocessingml.document".equals(fileType) || "application/msword".equals(fileType) || "application/pdf".equals(fileType) || "image/jpeg".equals(fileType)){
   String fileName = serviceFile.getOriginalFilename();
   try {
		InputStream in = serviceFile.getInputStream();
		FileOutputStream out = new FileOutputStream(savePath + "\\" + fileName);
		//创建一个缓冲区
	    byte buffer[] = new byte[1024];
	    //判断输入流中的数据是否已经读完的标识
		int len = 0;
		 while((len=in.read(buffer))>0){
			//使用FileOutputStream输出流将缓冲区的数据写入到指定的目录(savePath + "\\" + filename)当中
			out.write(buffer, 0, len);
			 }
			//关闭输入流
			in.close();
			//关闭输出流
			out.close();
	} catch (IOException e) {
		
		e.printStackTrace();
	}
	ServiceApplication serviceApplication = new ServiceApplication();
	serviceApplication.setIn_ID(Integer.parseInt(Comp));
	serviceApplication.setSer_id(Integer.parseInt(serType));
	serviceApplication.setsFile(fileName);
	serviceApplication.setCreateTime(new Timestamp(new Date().getTime()));
	serviceApplication.setOperator("admin");
	constructionService.addServiceApplication(serviceApplication);
   }
		return new ModelAndView(FWSQ_PAGE);
 		}
	
	@RequestMapping(value="/conLogUpload")
	public ModelAndView conLogUpload(@RequestParam("Comp1") String Comp1,@RequestParam("maskFile") MultipartFile maskFile,@RequestParam("logMessage") String logMessage){

		String savePath = SAVE_PATH+"constructionLog";
        File file = new File(savePath);
        //判断上传文件的保存目录是否存在
       if (!file.exists() && !file.isDirectory()) {
            //创建目录
            file.mkdir();
       }
   String fileType = maskFile.getContentType();
   if("application/vnd.openxmlformats-officedocument.wordprocessingml.document".equals(fileType) || "application/msword".equals(fileType) || "application/pdf".equals(fileType) || "image/jpeg".equals(fileType)){
   String fileName = maskFile.getOriginalFilename();
   try {
		InputStream in = maskFile.getInputStream();
		FileOutputStream out = new FileOutputStream(savePath + "\\" + fileName);
		//创建一个缓冲区
	    byte buffer[] = new byte[1024];
	    //判断输入流中的数据是否已经读完的标识
		int len = 0;
		 while((len=in.read(buffer))>0){
			//使用FileOutputStream输出流将缓冲区的数据写入到指定的目录(savePath + "\\" + filename)当中
			out.write(buffer, 0, len);
			 }
			//关闭输入流
			in.close();
			//关闭输出流
			out.close();
	} catch (IOException e) {
		
		e.printStackTrace();
	}
   ConstructionLog constructionLog = new ConstructionLog();
	constructionLog.setIn_ID(Integer.parseInt(Comp1));
	constructionLog.setCreateTime(new Timestamp(new Date().getTime()));
	constructionLog.setMask(logMessage);
	constructionLog.setOperator("admin");
	constructionLog.setType("1");
	constructionLog.setUpdateFile(fileName);
	constructionService.addConstructionLog(constructionLog);
	
   }
		return new ModelAndView(SGRZ_PAGE);
 		}
	
	@RequestMapping(value="/deductUpload")
	public ModelAndView deductUpload(@RequestParam("Comp") String Comp,@RequestParam("dType") String dType,@RequestParam("cashFile") MultipartFile cashFile,@RequestParam("dMessage") String dMessage) throws Throwable{
		String savePath = SAVE_PATH+"constructionLog";
        File file = new File(savePath);
        //判断上传文件的保存目录是否存在
       if (!file.exists() && !file.isDirectory()) {
            //创建目录
            file.mkdir();
       }
   String fileType = cashFile.getContentType();
   if("application/vnd.openxmlformats-officedocument.wordprocessingml.document".equals(fileType) || "application/msword".equals(fileType) || "application/pdf".equals(fileType) || "image/jpeg".equals(fileType)){
   String fileName = cashFile.getOriginalFilename();
   try {
		InputStream in = cashFile.getInputStream();
		FileOutputStream out = new FileOutputStream(savePath + "\\" + fileName);
		//创建一个缓冲区
	    byte buffer[] = new byte[1024];
	    //判断输入流中的数据是否已经读完的标识
		int len = 0;
		 while((len=in.read(buffer))>0){
			//使用FileOutputStream输出流将缓冲区的数据写入到指定的目录(savePath + "\\" + filename)当中
			out.write(buffer, 0, len);
			 }
			//关闭输入流
			in.close();
			//关闭输出流
			out.close();
	} catch (IOException e) {
		
		e.printStackTrace();
	}
		ConstructionLog constructionLog = new ConstructionLog();
		constructionLog.setIn_ID(Integer.parseInt(Comp));
		constructionLog.setCreateTime(new Timestamp(new Date().getTime()));
		constructionLog.setMask(dMessage);
		constructionLog.setOperator("admin");
		constructionLog.setType("2");
		constructionLog.setUpdateFile(fileName);
		constructionService.addClAndDh(constructionLog, Integer.parseInt(dType));
   }
		return new ModelAndView(SGRZ_PAGE);
 		}
	
	@RequestMapping(value="/bondUpload")
	public ModelAndView bondUpload(@RequestParam("Comp") String Comp,@RequestParam("balance") String balance,@RequestParam("bondFile") MultipartFile bondFile,HttpServletRequest req){
	    String savePath = SAVE_PATH+"bondManage";
        File file = new File(savePath);
        //判断上传文件的保存目录是否存在
       if (!file.exists() && !file.isDirectory()) {
            //创建目录
            file.mkdir();
       }
   String fileType = bondFile.getContentType();
   if("application/vnd.openxmlformats-officedocument.wordprocessingml.document".equals(fileType) || "application/msword".equals(fileType) || "application/pdf".equals(fileType) || "image/jpeg".equals(fileType)){
   String fileName = bondFile.getOriginalFilename();
   try {
		InputStream in = bondFile.getInputStream();
		FileOutputStream out = new FileOutputStream(savePath + "\\" + fileName);
		//创建一个缓冲区
	    byte buffer[] = new byte[1024];
	    //判断输入流中的数据是否已经读完的标识
		int len = 0;
		 while((len=in.read(buffer))>0){
			//使用FileOutputStream输出流将缓冲区的数据写入到指定的目录(savePath + "\\" + filename)当中
			out.write(buffer, 0, len);
			 }
			//关闭输入流
			in.close();
			//关闭输出流
			out.close();
	} catch (IOException e) {
		
		e.printStackTrace();
	}
	CorridorOut corridorOut = new CorridorOut();
	corridorOut.setIn_ID(Integer.parseInt(Comp));
	corridorOut.setStatus("2");
	corridorOut.setBondFile(fileName);
	corridorOut.setPayOperator("admin");
	corridorOut.setBalance(Double.parseDouble(balance));
	corridorOut.setBackBalance(Double.parseDouble(balance));
	corridorOut.setUpdateTime(new Timestamp(new Date().getTime()));
	constructionService.updateBond(corridorOut);
	
   }
		return new ModelAndView(BZJGL_PAGE);
 		}
	
	@RequestMapping(value="/backUpload")
	public ModelAndView backUpload(@RequestParam("cId") String cId,@RequestParam("backFile") MultipartFile backFile,HttpServletRequest req){
	    String savePath = SAVE_PATH+"backManage";
        File file = new File(savePath);
        //判断上传文件的保存目录是否存在
       if (!file.exists() && !file.isDirectory()) {
            //创建目录
            file.mkdir();
       }
   String fileType = backFile.getContentType();
   if("application/vnd.openxmlformats-officedocument.wordprocessingml.document".equals(fileType) || "application/msword".equals(fileType) || "application/pdf".equals(fileType) || "image/jpeg".equals(fileType)){
   String fileName = backFile.getOriginalFilename();
   try {
		InputStream in = backFile.getInputStream();
		FileOutputStream out = new FileOutputStream(savePath + "\\" + fileName);
		//创建一个缓冲区
	    byte buffer[] = new byte[1024];
	    //判断输入流中的数据是否已经读完的标识
		int len = 0;
		 while((len=in.read(buffer))>0){
			//使用FileOutputStream输出流将缓冲区的数据写入到指定的目录(savePath + "\\" + filename)当中
			out.write(buffer, 0, len);
			 }
			//关闭输入流
			in.close();
			//关闭输出流
			out.close();
	} catch (IOException e) {
		
		e.printStackTrace();
	}
	CorridorOut corridorOut = new CorridorOut();
	corridorOut.setId(Integer.parseInt(cId));
	corridorOut.setStatus("3");
	corridorOut.setBackOperator("admin");
	corridorOut.setBackFile(fileName);
	constructionService.updateBack(corridorOut);
   }
		return new ModelAndView(BZJGL_PAGE);
 		}
	
	@RequestMapping(value="/acceptDownload")
	public void acceptDownload(HttpServletRequest req, HttpServletResponse res){
		InputStream is = null;
		OutputStream os = null;
		try {
			res.reset();
			String fileName = "综合管廊入廊申请表模板.pdf";
			 if(req.getHeader("User-Agent").toLowerCase().indexOf("firefox")>0){
	                fileName = new String(fileName.getBytes("UTF-8"), "ISO8859-1");//firefox浏览器
	            }else if (req.getHeader("User-Agent").toUpperCase().indexOf("MSIE")>0){
	                fileName = URLEncoder.encode(fileName, "UTF-8");//IE浏览器
	            }else{
	                fileName = URLEncoder.encode(fileName, "UTF-8");
	            }
		res.setCharacterEncoding("utf-8");
		res.setContentType("application/pdf");
		res.setHeader("Content-Disposition", "attachment;fileName=\"" + fileName + "\"");

            String path = Thread.currentThread().getContextClassLoader()
                    .getResource("").getPath()
                    + "download";//这个tunneled目录为啥建立在classes下的
            is = new FileInputStream(new File(path
                    + File.separator + "综合管廊入廊申请表模板.pdf"));
 
            os = res.getOutputStream();
            byte[] mybyte = new byte[8192];
            int len = 0;
            while ((len = is.read(mybyte)) != -1) {
                os.write(mybyte, 0, len);
            }

            os.flush();
             // 这里主要关闭。
            os.close();
            is.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
	}
	
	@RequestMapping(value="/examineDownload")
	public void examineDownload(HttpServletRequest req, HttpServletResponse res){
		InputStream is = null;
		OutputStream os = null;
		try {
			res.reset();
			String fileName = "综合管廊入廊施工审核表模板.pdf";
			 if(req.getHeader("User-Agent").toLowerCase().indexOf("firefox")>0){
	                fileName = new String(fileName.getBytes("UTF-8"), "ISO8859-1");//firefox浏览器
	            }else if (req.getHeader("User-Agent").toUpperCase().indexOf("MSIE")>0){
	                fileName = URLEncoder.encode(fileName, "UTF-8");//IE浏览器
	            }else{
	                fileName = URLEncoder.encode(fileName, "UTF-8");
	            }
		res.setCharacterEncoding("utf-8");
		res.setContentType("application/pdf");
		res.setHeader("Content-Disposition", "attachment;fileName=\"" + fileName + "\"");

            String path = Thread.currentThread().getContextClassLoader()
                    .getResource("").getPath()
                    + "download";//这个tunneled目录为啥建立在classes下的
            is = new FileInputStream(new File(path
                    + File.separator + "综合管廊入廊施工审核表模板.pdf"));
 
            os = res.getOutputStream();
            byte[] mybyte = new byte[8192];
            int len = 0;
            while ((len = is.read(mybyte)) != -1) {
                os.write(mybyte, 0, len);
            }

            os.flush();
             // 这里主要关闭。
            os.close();
            is.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
	}
	
	@RequestMapping(value="/agreementDownload")
	public void agreementDownload(HttpServletRequest req, HttpServletResponse res){
		InputStream is = null;
		OutputStream os = null;
		try {
			res.reset();
			String fileName = "综合管廊管线入廊合同模板.pdf";
			 if(req.getHeader("User-Agent").toLowerCase().indexOf("firefox")>0){
	                fileName = new String(fileName.getBytes("UTF-8"), "ISO8859-1");//firefox浏览器
	            }else if (req.getHeader("User-Agent").toUpperCase().indexOf("MSIE")>0){
	                fileName = URLEncoder.encode(fileName, "UTF-8");//IE浏览器
	            }else{
	                fileName = URLEncoder.encode(fileName, "UTF-8");
	            }
		res.setCharacterEncoding("utf-8");
		res.setContentType("application/pdf");
		res.setHeader("Content-Disposition", "attachment;fileName=\"" + fileName + "\"");

            String path = Thread.currentThread().getContextClassLoader()
                    .getResource("").getPath()
                    + "download";//这个tunneled目录为啥建立在classes下的
            is = new FileInputStream(new File(path
                    + File.separator + "综合管廊管线入廊合同模板.pdf"));
 
            os = res.getOutputStream();
            byte[] mybyte = new byte[8192];
            int len = 0;
            while ((len = is.read(mybyte)) != -1) {
                os.write(mybyte, 0, len);
            }

            os.flush();
             // 这里主要关闭。
            os.close();
            is.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
	}
	
	@RequestMapping(value="/fireSafetyDownload")
	public void fireSafetyDownload(HttpServletRequest req, HttpServletResponse res){
		InputStream is = null;
		OutputStream os = null;
		try {
			res.reset();
			String fileName = "消防安全承诺书模板.pdf";
			 if(req.getHeader("User-Agent").toLowerCase().indexOf("firefox")>0){
	                fileName = new String(fileName.getBytes("UTF-8"), "ISO8859-1");//firefox浏览器
	            }else if (req.getHeader("User-Agent").toUpperCase().indexOf("MSIE")>0){
	                fileName = URLEncoder.encode(fileName, "UTF-8");//IE浏览器
	            }else{
	                fileName = URLEncoder.encode(fileName, "UTF-8");
	            }
		res.setCharacterEncoding("utf-8");
		res.setContentType("application/pdf");
		res.setHeader("Content-Disposition", "attachment;fileName=\"" + fileName + "\"");

            String path = Thread.currentThread().getContextClassLoader()
                    .getResource("").getPath()
                    + "download";//这个tunneled目录为啥建立在classes下的
            is = new FileInputStream(new File(path
                    + File.separator + "消防安全承诺书模板.pdf"));
 
            os = res.getOutputStream();
            byte[] mybyte = new byte[8192];
            int len = 0;
            while ((len = is.read(mybyte)) != -1) {
                os.write(mybyte, 0, len);
            }

            os.flush();
             // 这里主要关闭。
            os.close();
            is.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
	}
	
	@RequestMapping(value="/constructionSafetyDownload")
	public void constructionSafetyDownload(HttpServletRequest req, HttpServletResponse res){
		InputStream is = null;
		OutputStream os = null;
		try {
			res.reset();
			String fileName = "入廊施工安全责任告知书模板.pdf";
			 if(req.getHeader("User-Agent").toLowerCase().indexOf("firefox")>0){
	                fileName = new String(fileName.getBytes("UTF-8"), "ISO8859-1");//firefox浏览器
	            }else if (req.getHeader("User-Agent").toUpperCase().indexOf("MSIE")>0){
	                fileName = URLEncoder.encode(fileName, "UTF-8");//IE浏览器
	            }else{
	                fileName = URLEncoder.encode(fileName, "UTF-8");
	            }
		res.setCharacterEncoding("utf-8");
		res.setContentType("application/pdf");
		res.setHeader("Content-Disposition", "attachment;fileName=\"" + fileName + "\"");

            String path = Thread.currentThread().getContextClassLoader()
                    .getResource("").getPath()
                    + "download";//这个tunneled目录为啥建立在classes下的
            is = new FileInputStream(new File(path
                    + File.separator + "入廊施工安全责任告知书模板.pdf"));
 
            os = res.getOutputStream();
            byte[] mybyte = new byte[8192];
            int len = 0;
            while ((len = is.read(mybyte)) != -1) {
                os.write(mybyte, 0, len);
            }

            os.flush();
             // 这里主要关闭。
            os.close();
            is.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
	}
	
	@RequestMapping(value="/safetyProductionAgreementDownload")
	public void safetyProductionAgreementDownload(HttpServletRequest req, HttpServletResponse res){
		InputStream is = null;
		OutputStream os = null;
		try {
			res.reset();
			String fileName = "入廊安全生产文明施工协议模板.pdf";
			 if(req.getHeader("User-Agent").toLowerCase().indexOf("firefox")>0){
	                fileName = new String(fileName.getBytes("UTF-8"), "ISO8859-1");//firefox浏览器
	            }else if (req.getHeader("User-Agent").toUpperCase().indexOf("MSIE")>0){
	                fileName = URLEncoder.encode(fileName, "UTF-8");//IE浏览器
	            }else{
	                fileName = URLEncoder.encode(fileName, "UTF-8");
	            }
		res.setCharacterEncoding("utf-8");
		res.setContentType("application/pdf");
		res.setHeader("Content-Disposition", "attachment;fileName=\"" + fileName + "\"");

            String path = Thread.currentThread().getContextClassLoader()
                    .getResource("").getPath()
                    + "download";//这个tunneled目录为啥建立在classes下的
            is = new FileInputStream(new File(path
                    + File.separator + "入廊安全生产文明施工协议模板.pdf"));
 
            os = res.getOutputStream();
            byte[] mybyte = new byte[8192];
            int len = 0;
            while ((len = is.read(mybyte)) != -1) {
                os.write(mybyte, 0, len);
            }

            os.flush();
             // 这里主要关闭。
            os.close();
            is.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
	}
	
	@RequestMapping(value="/electroAppDownload")
	public void electroAppDownload(HttpServletRequest req, HttpServletResponse res){
		InputStream is = null;
		OutputStream os = null;
		try {
			res.reset();
			String fileName = "综合管廊用电申请单模板.pdf";
			 if(req.getHeader("User-Agent").toLowerCase().indexOf("firefox")>0){
	                fileName = new String(fileName.getBytes("UTF-8"), "ISO8859-1");//firefox浏览器
	            }else if (req.getHeader("User-Agent").toUpperCase().indexOf("MSIE")>0){
	                fileName = URLEncoder.encode(fileName, "UTF-8");//IE浏览器
	            }else{
	                fileName = URLEncoder.encode(fileName, "UTF-8");
	            }
		res.setCharacterEncoding("utf-8");
		res.setContentType("application/pdf");
		res.setHeader("Content-Disposition", "attachment;fileName=\"" + fileName + "\"");

            String path = Thread.currentThread().getContextClassLoader()
                    .getResource("").getPath()
                    + "download";//这个tunneled目录为啥建立在classes下的
            is = new FileInputStream(new File(path
                    + File.separator + "综合管廊用电申请单模板.pdf"));
 
            os = res.getOutputStream();
            byte[] mybyte = new byte[8192];
            int len = 0;
            while ((len = is.read(mybyte)) != -1) {
                os.write(mybyte, 0, len);
            }

            os.flush();
             // 这里主要关闭。
            os.close();
            is.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
	}
	
	@RequestMapping(value="/hotWorkDownload")
	public void hotWorkDownload(HttpServletRequest req, HttpServletResponse res){
		InputStream is = null;
		OutputStream os = null;
		try {
			res.reset();
			String fileName = "综合管廊动火证模板.pdf";
			 if(req.getHeader("User-Agent").toLowerCase().indexOf("firefox")>0){
	                fileName = new String(fileName.getBytes("UTF-8"), "ISO8859-1");//firefox浏览器
	            }else if (req.getHeader("User-Agent").toUpperCase().indexOf("MSIE")>0){
	                fileName = URLEncoder.encode(fileName, "UTF-8");//IE浏览器
	            }else{
	                fileName = URLEncoder.encode(fileName, "UTF-8");
	            }
		res.setCharacterEncoding("utf-8");
		res.setContentType("application/pdf");
		res.setHeader("Content-Disposition", "attachment;fileName=\"" + fileName + "\"");

            String path = Thread.currentThread().getContextClassLoader()
                    .getResource("").getPath()
                    + "download";//这个tunneled目录为啥建立在classes下的
            is = new FileInputStream(new File(path
                    + File.separator + "综合管廊动火证模板.pdf"));
 
            os = res.getOutputStream();
            byte[] mybyte = new byte[8192];
            int len = 0;
            while ((len = is.read(mybyte)) != -1) {
                os.write(mybyte, 0, len);
            }

            os.flush();
             // 这里主要关闭。
            os.close();
            is.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
	}
	
	@RequestMapping(value="/dismantleMoveDownload")
	public void dismantleMoveDownload(HttpServletRequest req, HttpServletResponse res){
		InputStream is = null;
		OutputStream os = null;
		try {
			res.reset();
			String fileName = "综合管廊结构改动或原有设施拆卸、移动申请表模板.pdf";
			 if(req.getHeader("User-Agent").toLowerCase().indexOf("firefox")>0){
	                fileName = new String(fileName.getBytes("UTF-8"), "ISO8859-1");//firefox浏览器
	            }else if (req.getHeader("User-Agent").toUpperCase().indexOf("MSIE")>0){
	                fileName = URLEncoder.encode(fileName, "UTF-8");//IE浏览器
	            }else{
	                fileName = URLEncoder.encode(fileName, "UTF-8");
	            }
		res.setCharacterEncoding("utf-8");
		res.setContentType("application/pdf");
		res.setHeader("Content-Disposition", "attachment;fileName=\"" + fileName + "\"");

            String path = Thread.currentThread().getContextClassLoader()
                    .getResource("").getPath()
                    + "download";//这个tunneled目录为啥建立在classes下的
            is = new FileInputStream(new File(path
                    + File.separator + "综合管廊结构改动或原有设施拆卸、移动申请表模板.pdf"));
 
            os = res.getOutputStream();
            byte[] mybyte = new byte[8192];
            int len = 0;
            while ((len = is.read(mybyte)) != -1) {
                os.write(mybyte, 0, len);
            }

            os.flush();
             // 这里主要关闭。
            os.close();
            is.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
	}

	@RequestMapping(value="/acceptGridDownload")
	public void acceptGridDownload(@RequestParam("file") String file,HttpServletRequest req, HttpServletResponse res){
		InputStream is = null;
		OutputStream os = null;
		try {
			res.reset();
			String fileName = new String(file.getBytes("ISO8859-1"),"UTF-8");
			String fName = "";
			if(req.getHeader("User-Agent").toLowerCase().indexOf("firefox")>0){
				fName = new String(fileName.getBytes("UTF-8"), "ISO8859-1");//firefox浏览器
            }else if (req.getHeader("User-Agent").toUpperCase().indexOf("MSIE")>0){
            	fName = URLEncoder.encode(fileName, "UTF-8");//IE浏览器
            }else{
            	fName = URLEncoder.encode(fileName, "UTF-8");
            }
			res.setCharacterEncoding("utf-8");
			
			if(fileName.contains("doc") || fileName.contains("docx")){
				res.setContentType("application/msword");
			}
            if(fileName.contains("pdf")){
            	res.setContentType("application/pdf");
			}
            if(fileName.contains("jpg")){
            	res.setContentType("image/jpeg");
            }
		
		res.setHeader("Content-Disposition", "attachment;fileName=\"" + fName + "\"");

            String path = SAVE_PATH+"acceptApplicationIn";
            File filePath = new File(path);
            is = new FileInputStream(new File(filePath
                    + File.separator + fileName));
 
            os = res.getOutputStream();
            byte[] mybyte = new byte[8192];
            int len = 0;
            while ((len = is.read(mybyte)) != -1) {
                os.write(mybyte, 0, len);
            }

            os.flush();
             // 这里主要关闭。
            os.close();
            is.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
	}
	
	@RequestMapping(value="/examineGridDownload")
	public void examineGridDownload(@RequestParam("file") String file,HttpServletRequest req, HttpServletResponse res){
		InputStream is = null;
		OutputStream os = null;
		try {
			res.reset();
			String fileName = new String(file.getBytes("ISO8859-1"),"UTF-8");
			String fName = "";
			if(req.getHeader("User-Agent").toLowerCase().indexOf("firefox")>0){
				fName = new String(fileName.getBytes("UTF-8"), "ISO8859-1");//firefox浏览器
            }else if (req.getHeader("User-Agent").toUpperCase().indexOf("MSIE")>0){
            	fName = URLEncoder.encode(fileName, "UTF-8");//IE浏览器
            }else{
            	fName = URLEncoder.encode(fileName, "UTF-8");
            }
            res.setCharacterEncoding("utf-8");
			
			if(fileName.contains("doc") || fileName.contains("docx")){
				res.setContentType("application/msword");
			}
            if(fileName.contains("pdf")){
            	res.setContentType("application/pdf");
			}
            if(fileName.contains("jpg")){
            	res.setContentType("image/jpeg");
            }
		
		res.setHeader("Content-Disposition", "attachment;fileName=\"" + fName + "\"");

            String path = SAVE_PATH+"examineIn";
            File filePath = new File(path);
            is = new FileInputStream(new File(filePath
                    + File.separator + fileName));
 
            os = res.getOutputStream();
            byte[] mybyte = new byte[8192];
            int len = 0;
            while ((len = is.read(mybyte)) != -1) {
                os.write(mybyte, 0, len);
            }

            os.flush();
             // 这里主要关闭。
            os.close();
            is.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
	}
	
	@RequestMapping(value="/agreementGridDownload")
	public void agreementGridDownload(@RequestParam("file") String file,HttpServletRequest req, HttpServletResponse res){
		InputStream is = null;
		OutputStream os = null;
		try {
			res.reset();
			String fileName = new String(file.getBytes("ISO8859-1"),"UTF-8");
			String fName = "";
			if(req.getHeader("User-Agent").toLowerCase().indexOf("firefox")>0){
				fName = new String(fileName.getBytes("UTF-8"), "ISO8859-1");//firefox浏览器
            }else if (req.getHeader("User-Agent").toUpperCase().indexOf("MSIE")>0){
            	fName = URLEncoder.encode(fileName, "UTF-8");//IE浏览器
            }else{
            	fName = URLEncoder.encode(fileName, "UTF-8");
            }
		res.setCharacterEncoding("utf-8");
		if(fileName.contains("doc") || fileName.contains("docx")){
			res.setContentType("application/msword");
		}
        if(fileName.contains("pdf")){
        	res.setContentType("application/pdf");
		}
        if(fileName.contains("jpg")){
        	res.setContentType("image/jpeg");
        }
		res.setHeader("Content-Disposition", "attachment;fileName=\"" + fName + "\"");

            String path = SAVE_PATH+"agreementIn";
            File filePath = new File(path);
            is = new FileInputStream(new File(filePath
                    + File.separator + fileName));
 
            os = res.getOutputStream();
            byte[] mybyte = new byte[8192];
            int len = 0;
            while ((len = is.read(mybyte)) != -1) {
                os.write(mybyte, 0, len);
            }

            os.flush();
             // 这里主要关闭。
            os.close();
            is.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
	}
	
	@RequestMapping(value="/downloadConstructionLog")
	public void downloadConstructionLog(@RequestParam("file") String file,HttpServletRequest req, HttpServletResponse res){
		InputStream is = null;
		OutputStream os = null;
		try {
			res.reset();
			String fileName = new String(file.getBytes("ISO8859-1"),"UTF-8");
			String fName = "";
			if(req.getHeader("User-Agent").toLowerCase().indexOf("firefox")>0){
				fName = new String(fileName.getBytes("UTF-8"), "ISO8859-1");//firefox浏览器
            }else if (req.getHeader("User-Agent").toUpperCase().indexOf("MSIE")>0){
            	fName = URLEncoder.encode(fileName, "UTF-8");//IE浏览器
            }else{
            	fName = URLEncoder.encode(fileName, "UTF-8");
            }
		res.setCharacterEncoding("utf-8");
		if(fileName.contains("doc") || fileName.contains("docx")){
			res.setContentType("application/msword");
		}
        if(fileName.contains("pdf")){
        	res.setContentType("application/pdf");
		}
        if(fileName.contains("jpg")){
        	res.setContentType("image/jpeg");
        }
		res.setHeader("Content-Disposition", "attachment;fileName=\"" + fName + "\"");

            String path = SAVE_PATH+"constructionLog";
            File filePath = new File(path);
            is = new FileInputStream(new File(filePath
                    + File.separator + fileName));
 
            os = res.getOutputStream();
            byte[] mybyte = new byte[8192];
            int len = 0;
            while ((len = is.read(mybyte)) != -1) {
                os.write(mybyte, 0, len);
            }

            os.flush();
             // 这里主要关闭。
            os.close();
            is.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
	}
	
	@RequestMapping(value="/downloadSupervisionLog")
	public void downloadSupervisionLog(@RequestParam("file") String file,HttpServletRequest req, HttpServletResponse res){
		
		InputStream is = null;
		OutputStream os = null;
		try {
			res.reset();
			String fileName = new String(file.getBytes("ISO8859-1"),"UTF-8");
			String fName = "";
			if(req.getHeader("User-Agent").toLowerCase().indexOf("firefox")>0){
				fName = new String(fileName.getBytes("UTF-8"), "ISO8859-1");//firefox浏览器
            }else if (req.getHeader("User-Agent").toUpperCase().indexOf("MSIE")>0){
            	fName = URLEncoder.encode(fileName, "UTF-8");//IE浏览器
            }else{
            	fName = URLEncoder.encode(fileName, "UTF-8");
            }
		res.setCharacterEncoding("utf-8");
		if(fileName.contains("doc") || fileName.contains("docx")){
			res.setContentType("application/msword");
		}
        if(fileName.contains("pdf")){
        	res.setContentType("application/pdf");
		}
        if(fileName.contains("jpg")){
        	res.setContentType("image/jpeg");
        }
		res.setHeader("Content-Disposition", "attachment;fileName=\"" + fName + "\"");

            String path = SAVE_PATH+"supervisionLog";
            File filePath = new File(path);
            is = new FileInputStream(new File(filePath
                    + File.separator + fileName));
 
            os = res.getOutputStream();
            byte[] mybyte = new byte[8192];
            int len = 0;
            while ((len = is.read(mybyte)) != -1) {
                os.write(mybyte, 0, len);
            }

            os.flush();
             // 这里主要关闭。
            os.close();
            is.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
	}
	
	@RequestMapping(value="/payVoucherDownload")
	public void payVoucherDownload(@RequestParam("file") String file,HttpServletRequest req, HttpServletResponse res){
		InputStream is = null;
		OutputStream os = null;
		try {
			res.reset();
			String fileName = new String(file.getBytes("ISO8859-1"),"UTF-8");
			String fName = "";
			if(req.getHeader("User-Agent").toLowerCase().indexOf("firefox")>0){
				fName = new String(fileName.getBytes("UTF-8"), "ISO8859-1");//firefox浏览器
            }else if (req.getHeader("User-Agent").toUpperCase().indexOf("MSIE")>0){
            	fName = URLEncoder.encode(fileName, "UTF-8");//IE浏览器
            }else{
            	fName = URLEncoder.encode(fileName, "UTF-8");
            }
		res.setCharacterEncoding("utf-8");
		if(fileName.contains("doc") || fileName.contains("docx")){
			res.setContentType("application/msword");
		}
        if(fileName.contains("pdf")){
        	res.setContentType("application/pdf");
		}
        if(fileName.contains("jpg")){
        	res.setContentType("image/jpeg");
        }
		res.setHeader("Content-Disposition", "attachment;fileName=\"" + fName + "\"");

            String path = SAVE_PATH+"paymentVoucher";
            File filePath = new File(path);
            is = new FileInputStream(new File(filePath
                    + File.separator + fileName));
 
            os = res.getOutputStream();
            byte[] mybyte = new byte[8192];
            int len = 0;
            while ((len = is.read(mybyte)) != -1) {
                os.write(mybyte, 0, len);
            }

            os.flush();
             // 这里主要关闭。
            os.close();
            is.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
	}
	
	@RequestMapping(value="/fireSafetyGridDownload")
	public void fireSafetyGridDownload(@RequestParam("file") String file,HttpServletRequest req, HttpServletResponse res){
		InputStream is = null;
		OutputStream os = null;
		try {
			res.reset();
			String fileName = new String(file.getBytes("ISO8859-1"),"UTF-8");
			String fName = "";
			if(req.getHeader("User-Agent").toLowerCase().indexOf("firefox")>0){
				fName = new String(fileName.getBytes("UTF-8"), "ISO8859-1");//firefox浏览器
            }else if (req.getHeader("User-Agent").toUpperCase().indexOf("MSIE")>0){
            	fName = URLEncoder.encode(fileName, "UTF-8");//IE浏览器
            }else{
            	fName = URLEncoder.encode(fileName, "UTF-8");
            }
		res.setCharacterEncoding("utf-8");
		if(fileName.contains("doc") || fileName.contains("docx")){
			res.setContentType("application/msword");
		}
        if(fileName.contains("pdf")){
        	res.setContentType("application/pdf");
		}
        if(fileName.contains("jpg")){
        	res.setContentType("image/jpeg");
        }
		res.setHeader("Content-Disposition", "attachment;fileName=\"" + fName + "\"");

            String path = SAVE_PATH+"fireSafety";
            File filePath = new File(path);
            is = new FileInputStream(new File(filePath
                    + File.separator + fileName));
 
            os = res.getOutputStream();
            byte[] mybyte = new byte[8192];
            int len = 0;
            while ((len = is.read(mybyte)) != -1) {
                os.write(mybyte, 0, len);
            }

            os.flush();
             // 这里主要关闭。
            os.close();
            is.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
	}
	
	@RequestMapping(value="/constructionSafetyGridDownload")
	public void constructionSafetyGridDownload(@RequestParam("file") String file,HttpServletRequest req, HttpServletResponse res){
		InputStream is = null;
		OutputStream os = null;
		try {
			res.reset();
			String fileName = new String(file.getBytes("ISO8859-1"),"UTF-8");
			String fName = "";
			if(req.getHeader("User-Agent").toLowerCase().indexOf("firefox")>0){
				fName = new String(fileName.getBytes("UTF-8"), "ISO8859-1");//firefox浏览器
            }else if (req.getHeader("User-Agent").toUpperCase().indexOf("MSIE")>0){
            	fName = URLEncoder.encode(fileName, "UTF-8");//IE浏览器
            }else{
            	fName = URLEncoder.encode(fileName, "UTF-8");
            }
		res.setCharacterEncoding("utf-8");
		if(fileName.contains("doc") || fileName.contains("docx")){
			res.setContentType("application/msword");
		}
        if(fileName.contains("pdf")){
        	res.setContentType("application/pdf");
		}
        if(fileName.contains("jpg")){
        	res.setContentType("image/jpeg");
        }
		res.setHeader("Content-Disposition", "attachment;fileName=\"" + fName + "\"");

            String path = SAVE_PATH+"constructionSafety";
            File filePath = new File(path);
            is = new FileInputStream(new File(filePath
                    + File.separator + fileName));
 
            os = res.getOutputStream();
            byte[] mybyte = new byte[8192];
            int len = 0;
            while ((len = is.read(mybyte)) != -1) {
                os.write(mybyte, 0, len);
            }

            os.flush();
             // 这里主要关闭。
            os.close();
            is.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
	}
	
	@RequestMapping(value="/safetyProductionAgreementGridDownload")
	public void safetyProductionAgreementGridDownload(@RequestParam("file") String file,HttpServletRequest req, HttpServletResponse res){
		InputStream is = null;
		OutputStream os = null;
		try {
			res.reset();
			String fileName = new String(file.getBytes("ISO8859-1"),"UTF-8");
			String fName = "";
			if(req.getHeader("User-Agent").toLowerCase().indexOf("firefox")>0){
				fName = new String(fileName.getBytes("UTF-8"), "ISO8859-1");//firefox浏览器
            }else if (req.getHeader("User-Agent").toUpperCase().indexOf("MSIE")>0){
            	fName = URLEncoder.encode(fileName, "UTF-8");//IE浏览器
            }else{
            	fName = URLEncoder.encode(fileName, "UTF-8");
            }
		res.setCharacterEncoding("utf-8");
		if(fileName.contains("doc") || fileName.contains("docx")){
			res.setContentType("application/msword");
		}
        if(fileName.contains("pdf")){
        	res.setContentType("application/pdf");
		}
        if(fileName.contains("jpg")){
        	res.setContentType("image/jpeg");
        }
		res.setHeader("Content-Disposition", "attachment;fileName=\"" + fName + "\"");

            String path = SAVE_PATH+"safetyProductionAgreement";
            File filePath = new File(path);
            is = new FileInputStream(new File(filePath
                    + File.separator + fileName));
 
            os = res.getOutputStream();
            byte[] mybyte = new byte[8192];
            int len = 0;
            while ((len = is.read(mybyte)) != -1) {
                os.write(mybyte, 0, len);
            }

            os.flush();
             // 这里主要关闭。
            os.close();
            is.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
	}
	
	@RequestMapping(value="/sFileGridDownload")
	public void sFileGridDownload(@RequestParam("file") String file,@RequestParam("type") String type,HttpServletRequest req, HttpServletResponse res){
		InputStream is = null;
		OutputStream os = null;
		try {
			res.reset();
			String fileName = new String(file.getBytes("ISO8859-1"),"UTF-8");
			String sType = new String(type.getBytes("ISO8859-1"),"UTF-8");
			String fName = "";
			if(req.getHeader("User-Agent").toLowerCase().indexOf("firefox")>0){
				fName = new String(fileName.getBytes("UTF-8"), "ISO8859-1");//firefox浏览器
            }else if (req.getHeader("User-Agent").toUpperCase().indexOf("MSIE")>0){
            	fName = URLEncoder.encode(fileName, "UTF-8");//IE浏览器
            }else{
            	fName = URLEncoder.encode(fileName, "UTF-8");
            }
		res.setCharacterEncoding("utf-8");
		if(fileName.contains("doc") || fileName.contains("docx")){
			res.setContentType("application/msword");
		}
        if(fileName.contains("pdf")){
        	res.setContentType("application/pdf");
		}
        if(fileName.contains("jpg")){
        	res.setContentType("image/jpeg");
        }
		res.setHeader("Content-Disposition", "attachment;fileName=\"" + fName + "\"");
		
		    String path = "";
		    if("用电".equals(sType)){
		    	path = SAVE_PATH+"electroApp";
		    }
		    else if("用火".equals(sType)){
		    	path = SAVE_PATH+"hotWork";
		    }
		    else if("设施移动/拆除".equals(sType)){
		    	path = SAVE_PATH+"dismantleMove";
		    }
            File filePath = new File(path);
            is = new FileInputStream(new File(filePath
                    + File.separator + fileName));
 
            os = res.getOutputStream();
            byte[] mybyte = new byte[8192];
            int len = 0;
            while ((len = is.read(mybyte)) != -1) {
                os.write(mybyte, 0, len);
            }

            os.flush();
             // 这里主要关闭。
            os.close();
            is.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
	}
	
	@RequestMapping(value="/bondFileDownload")
	public void bondFileDownload(@RequestParam("file") String file,HttpServletRequest req, HttpServletResponse res){
		InputStream is = null;
		OutputStream os = null;
		try {
			res.reset();
			String fileName = new String(file.getBytes("ISO8859-1"),"UTF-8");
			String fName = "";
			if(req.getHeader("User-Agent").toLowerCase().indexOf("firefox")>0){
				fName = new String(fileName.getBytes("UTF-8"), "ISO8859-1");//firefox浏览器
            }else if (req.getHeader("User-Agent").toUpperCase().indexOf("MSIE")>0){
            	fName = URLEncoder.encode(fileName, "UTF-8");//IE浏览器
            }else{
            	fName = URLEncoder.encode(fileName, "UTF-8");
            }
		res.setCharacterEncoding("utf-8");
		if(fileName.contains("doc") || fileName.contains("docx")){
			res.setContentType("application/msword");
		}
        if(fileName.contains("pdf")){
        	res.setContentType("application/pdf");
		}
        if(fileName.contains("jpg")){
        	res.setContentType("image/jpeg");
        }
		res.setHeader("Content-Disposition", "attachment;fileName=\"" + fName + "\"");

            String path = SAVE_PATH+"bondManage";
            File filePath = new File(path);
            is = new FileInputStream(new File(filePath
                    + File.separator + fileName));
 
            os = res.getOutputStream();
            byte[] mybyte = new byte[8192];
            int len = 0;
            while ((len = is.read(mybyte)) != -1) {
                os.write(mybyte, 0, len);
            }

            os.flush();
             // 这里主要关闭。
            os.close();
            is.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
	}
	
	@RequestMapping(value="/backFileDownload")
	public void backFileDownload(@RequestParam("file") String file,HttpServletRequest req, HttpServletResponse res){
		InputStream is = null;
		OutputStream os = null;
		try {
			res.reset();
			String fileName = new String(file.getBytes("ISO8859-1"),"UTF-8");
			String fName = "";
			if(req.getHeader("User-Agent").toLowerCase().indexOf("firefox")>0){
				fName = new String(fileName.getBytes("UTF-8"), "ISO8859-1");//firefox浏览器
            }else if (req.getHeader("User-Agent").toUpperCase().indexOf("MSIE")>0){
            	fName = URLEncoder.encode(fileName, "UTF-8");//IE浏览器
            }else{
            	fName = URLEncoder.encode(fileName, "UTF-8");
            }
		res.setCharacterEncoding("utf-8");
		if(fileName.contains("doc") || fileName.contains("docx")){
			res.setContentType("application/msword");
		}
        if(fileName.contains("pdf")){
        	res.setContentType("application/pdf");
		}
        if(fileName.contains("jpg")){
        	res.setContentType("image/jpeg");
        }
		res.setHeader("Content-Disposition", "attachment;fileName=\"" + fName + "\"");

            String path = SAVE_PATH+"backManage";
            File filePath = new File(path);
            is = new FileInputStream(new File(filePath
                    + File.separator + fileName));
 
            os = res.getOutputStream();
            byte[] mybyte = new byte[8192];
            int len = 0;
            while ((len = is.read(mybyte)) != -1) {
                os.write(mybyte, 0, len);
            }

            os.flush();
             // 这里主要关闭。
            os.close();
            is.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
	}
	
	@RequestMapping(value="/feeConfigUpdate")
	public void feeConfigUpdate(@ModelAttribute FeeConfig fConfig){
		
		FeeConfig feeConfig=new FeeConfig();
		feeConfig.setFC1(fConfig.getFC1());
		feeConfig.setR1(fConfig.getR1());
		feeConfig.setN1(fConfig.getN1());
		feeConfig.setPC1(fConfig.getPC1());
		feeConfig.setPCR1(fConfig.getPCR1());
		feeConfig.setDC1(fConfig.getDC1());
		feeConfig.setK1(fConfig.getK1());
		
		feeConfig.setRC21(fConfig.getRC21());
		feeConfig.setRC22(fConfig.getRC22());
		feeConfig.setMC2(fConfig.getMC2());
		feeConfig.setR2(fConfig.getR2());
		
		feeConfig.setV3(fConfig.getV3());
		feeConfig.setA(fConfig.getA());
		feeConfig.setB(fConfig.getB());
		procedureService.updateFeeConfig(feeConfig);		
		
	}
	
	@RequestMapping(value = "/loadFeeConfig")
	@ResponseBody
	public Object loadFeeConfig() {
		List<FeeConfig> data =procedureService.findFeeConfig();
		return data;
	}
	
	@RequestMapping(value="/feeCalculate")
	@ResponseBody
	public Object feeCalculate(@RequestParam("place") String place,@RequestParam("ePile") String ePile,@RequestParam("sPile") String sPile){
		try {
			place = new String(place.getBytes("ISO8859-1"),"UTF-8");
			ePile = new String(ePile.getBytes("ISO8859-1"),"UTF-8");
			sPile = new String(sPile.getBytes("ISO8859-1"),"UTF-8");
		} catch (UnsupportedEncodingException e) {
			
			e.printStackTrace();
		}
		//获得配置信息
		List<FeeConfig> data=procedureService.findFeeConfig();
		int tun_id=data.get(0).getTun_id();
		double FC1=Double.parseDouble(String.valueOf(data.get(0).getFC1()));
		double R1=Double.parseDouble(String.valueOf(data.get(0).getR1()))/100;
		double N1=Double.parseDouble(String.valueOf(data.get(0).getN1()));
		double PC1=Double.parseDouble(String.valueOf(data.get(0).getPC1()));
		double PCR1=Double.parseDouble(String.valueOf(data.get(0).getPCR1()));
		double DC1=Double.parseDouble(String.valueOf(data.get(0).getDC1()));
		double K1=Double.parseDouble(String.valueOf(data.get(0).getK1()));
		
		double RC21=Double.parseDouble(String.valueOf(data.get(0).getRC21()));
		double RC22=Double.parseDouble(String.valueOf(data.get(0).getRC22()));
		double MC2=Double.parseDouble(String.valueOf(data.get(0).getMC2()));
		double R2=Double.parseDouble(String.valueOf(data.get(0).getR2()))/100;
		
		double V3=Double.parseDouble(String.valueOf(data.get(0).getV3()));
		double A=Double.parseDouble(String.valueOf(data.get(0).getA()));
		double B=Double.parseDouble(String.valueOf(data.get(0).getB()));
		
		
		//判断线路类型，确定管线使用强度
		double UF=0.12;
		if(place.contains("电力")){
			UF=0.12;
		}else if(place.contains("通信")){
			UF=0.1;
		}else if(place.contains("水")){
			UF=0.18;
		}
		
		//计算线路长度
		char ep[]=ePile.toCharArray();
		String epn="";
		for(int i=0;i<ep.length;i++){
			if(String.valueOf(ep[i]).matches("[0-9]+")){
				epn+=ep[i];
			}
		}
		
		char sp[]=sPile.toCharArray();
		String spn="";
		for(int i=0;i<sp.length;i++){
			if(String.valueOf(sp[i]).matches("[0-9]+")){
				spn+=sp[i];
			}
		}
		double L=Integer.valueOf(epn)-Integer.valueOf(spn);
		L=(L>=0?L:-L);
		
		Map<String,Object> m = new HashMap<String,Object>();
		
		//未计算的管线截面面积和管线直径
		double D=0.2;
		double S=3.14*D*D/4;
		
		//入廊管线占用空间
		double P=S*L/V3;
		
		//管线入廊费用计算
		double TC=(K1*(FC1*P*Math.pow(1+R1,N1)+A*PC1+B*PCR1))-DC1;
		
		
		//入廊管线维护费用
		double RPC=RC21*P+UF*P*RC22+MC2+MC2*R2;
		
        DecimalFormat df = new DecimalFormat ("#.####");
		
		m.put("uf",df.format(UF));
		m.put("l", df.format(L));
		m.put("s", df.format(S));
		m.put("d", df.format(D));
		m.put("p", df.format((P*100)));
		m.put("tc", df.format(TC));
		m.put("rpc",df.format(RPC));
	 
		return m;
	}

	@RequestMapping(value="/fayzdownload")
	public void fayzdownload(@RequestParam("file") String file,HttpServletRequest req, HttpServletResponse res){

		InputStream is = null;
		OutputStream os = null;
		try {
			res.reset();
			String fileName = new String(file.getBytes("ISO8859-1"),"UTF-8");
			String fName = "";
			if(req.getHeader("User-Agent").toLowerCase().indexOf("firefox")>0){
				fName = new String(fileName.getBytes("UTF-8"), "ISO8859-1");//firefox浏览器
			}else if (req.getHeader("User-Agent").toUpperCase().indexOf("MSIE")>0){
				fName = URLEncoder.encode(fileName, "UTF-8");//IE浏览器
			}else{
				fName = URLEncoder.encode(fileName, "UTF-8");
			}
			res.setCharacterEncoding("utf-8");
			if(fileName.contains("doc") || fileName.contains("docx")){
				res.setContentType("application/msword");
			}
			if(fileName.contains("pdf")){
				res.setContentType("application/pdf");
			}
			if(fileName.contains("jpg")){
				res.setContentType("image/jpeg");
			}
			res.setHeader("Content-Disposition", "attachment;fileName=\"" + fName + "\"");

			String path = SAVE_PATH+"fayzIn";
			File filePath = new File(path);
			is = new FileInputStream(new File(filePath
					+ File.separator + fileName));

			os = res.getOutputStream();
			byte[] mybyte = new byte[8192];
			int len = 0;
			while ((len = is.read(mybyte)) != -1) {
				os.write(mybyte, 0, len);
			}

			os.flush();
			// 这里主要关闭。
			os.close();
			is.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}


